# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=c-ares

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.10.0
pkgrel=1
pkgdesc="C library that performs DNS requests and name resolves asynchronously (mingw-w64)"
arch=('any')
url="http://c-ares.haxx.se/"
license=("MIT, BSD")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
options=(strip staticlibs)
source=("http://c-ares.haxx.se/download/${_realname}-$pkgver.tar.gz"{,.asc}
        0001-Use-RPM-compiler-options.patch)
sha1sums=('e44e6575d5af99cb3a38461486e1ee8b49810eb5'
          'SKIP'
          '7e1c721c5f4efd49db998209eaa9b80bea1a9819')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0001-Use-RPM-compiler-options.patch
  
  autoreconf -fi
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  "${srcdir}"/${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="$pkgdir" install
}
